GtkListBox: Make reseparate a no-op for hidden lists
authorAlexander Larsson <alexl@redhat.com>
Tue, 11 Jun 2013 14:04:58 +0000 (16:04 +0200)
committerAlexander Larsson <alexl@redhat.com>
Thu, 13 Jun 2013 10:17:07 +0000 (12:17 +0200)
We already take care to not track headers when the listbox is hidden,
because that can be very expensive during creation, so we might as
well skip reseparate() too. The only time we don't want to skip it
is when we're about to show the list.

gtk/gtklistbox.c

index 20e8d98c1048237e2622eaa69139f8ff20120695..82929776732ed767491ced2d7db45951dfd830e0 100644 (file)
@@ -815,6 +815,21 @@ gtk_list_box_resort (GtkListBox *list_box)
   gtk_widget_queue_resize (GTK_WIDGET (list_box));
 }
 
+static void
+gtk_list_box_do_reseparate (GtkListBox *list_box)
+{
+  GtkListBoxPrivate *priv = list_box->priv;
+  GSequenceIter *iter;
+
+  for (iter = g_sequence_get_begin_iter (priv->children);
+       !g_sequence_iter_is_end (iter);
+       iter = g_sequence_iter_next (iter))
+    gtk_list_box_update_header (list_box, iter);
+
+  gtk_widget_queue_resize (GTK_WIDGET (list_box));
+}
+
+
 /**
  * gtk_list_box_reseparate:
  * @list_box: a #GtkListBox
@@ -828,17 +843,12 @@ gtk_list_box_resort (GtkListBox *list_box)
 void
 gtk_list_box_reseparate (GtkListBox *list_box)
 {
-  GtkListBoxPrivate *priv = list_box->priv;
-  GSequenceIter *iter;
-
   g_return_if_fail (list_box != NULL);
 
-  for (iter = g_sequence_get_begin_iter (priv->children);
-       !g_sequence_iter_is_end (iter);
-       iter = g_sequence_iter_next (iter))
-    gtk_list_box_update_header (list_box, iter);
+  if (!gtk_widget_get_visible (GTK_WIDGET (list_box)))
+    return;
 
-  gtk_widget_queue_resize (GTK_WIDGET (list_box));
+  gtk_list_box_do_reseparate (list_box);
 }
 
 /**
@@ -1186,7 +1196,7 @@ gtk_list_box_real_show (GtkWidget *widget)
 {
   GtkListBox * list_box = GTK_LIST_BOX (widget);
 
-  gtk_list_box_reseparate (list_box);
+  gtk_list_box_do_reseparate (list_box);
 
   GTK_WIDGET_CLASS (gtk_list_box_parent_class)->show (widget);
 }